<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/avatar.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/avatar.jpg">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-big-counter.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"raphets.github.io","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"hide","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"default"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="序列化，将对象的状态信息转换为可以存储或传输的形式的过程。">
<meta property="og:type" content="article">
<meta property="og:title" content="Android 序列化总结">
<meta property="og:url" content="https://raphets.github.io/archives/aa588849.html">
<meta property="og:site_name" content="尚拙">
<meta property="og:description" content="序列化，将对象的状态信息转换为可以存储或传输的形式的过程。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2019-04-29T01:52:35.000Z">
<meta property="article:modified_time" content="2024-01-30T05:04:46.461Z">
<meta property="article:author" content="John Doe">
<meta property="article:tag" content="Android，技术，学习，成长">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://raphets.github.io/archives/aa588849.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Android 序列化总结 | 尚拙</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">尚拙</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">一个分享技术、学习成长的个人博客网站</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
        <li class="menu-item menu-item-tool">

    <a href="/tool/" rel="section"><i class="fa fa-hammer fa-fw"></i>工具</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://raphets.github.io/archives/aa588849.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="John Doe">
      <meta itemprop="description" content="不积跬步，无以至千里；不积小流，无以成江海。">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="尚拙">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Android 序列化总结
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-04-29 09:52:35" itemprop="dateCreated datePublished" datetime="2019-04-29T09:52:35+08:00">2019-04-29</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-01-30 13:04:46" itemprop="dateModified" datetime="2024-01-30T13:04:46+08:00">2024-01-30</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/" itemprop="url" rel="index"><span itemprop="name">技术文章</span></a>
                </span>
                  ，
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%8A%80%E6%9C%AF%E6%96%87%E7%AB%A0/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>序列化，将对象的状态信息转换为可以存储或传输的形式的过程。</p>
<span id="more"></span>

<p>在序列化期间，对象将其当前状态写入到临时或持久性存储区。以后，可以通过从存储区中读取或反序列化对象的状态，重新创建该对象。</p>
<h1 id="一、概念"><a href="#一、概念" class="headerlink" title="一、概念"></a>一、概念</h1><p>Java序列化是指把Java对象转换为字节序列的过程；</p>
<p>而Java反序列化是指把字节序列恢复为Java对象的过程。</p>
<h1 id="二、用途"><a href="#二、用途" class="headerlink" title="二、用途"></a>二、用途</h1><p>1、实现了数据的持久化，通过序列化可以把数据永久地保存到硬盘上（通常存放在文件里）</p>
<p>2、通过序列化对象在网络中传递对象。</p>
<p>3、通过序列化对象在进程间传递对象。</p>
<h1 id="三、Serializable接口实现序列化"><a href="#三、Serializable接口实现序列化" class="headerlink" title="三、Serializable接口实现序列化"></a>三、Serializable接口实现序列化</h1><p>Serializable的作用是为了保存对象的属性到本地文件、数据库、网络流、rmi以方便数据传输，当然这种传输可以是程序内的也可以是两个程序间的。</p>
<p>对于Serializable，类只需要实现Serializable接口，并提供一个序列化版本id(serialVersionUID)即可。</p>
<h4 id="Ⅰ、Android-Studio自动生成SerizlVersionUID"><a href="#Ⅰ、Android-Studio自动生成SerizlVersionUID" class="headerlink" title="Ⅰ、Android Studio自动生成SerizlVersionUID:"></a>Ⅰ、Android Studio自动生成SerizlVersionUID:</h4><p>1、File -&gt; Settings… -&gt; Editor -&gt; Inspections -&gt; Serialization issues -&gt; Serializable class without ‘serialVersionUID‘（选中）</p>
<p>2、进入实现了Serializable中的类，选中类名，Alt+Enter弹出提示，然后直接导入完成.</p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">package org.raphets.democollection;</span><br><span class="line">import java.io.Serializable;</span><br><span class="line"></span><br><span class="line">public class Dog implements Serializable&#123;</span><br><span class="line">    private static final long serialVersionUID = -2457171891775313955L;</span><br><span class="line">    private String name;</span><br><span class="line">    private int age;</span><br><span class="line">    public Dog(String name, int age) &#123;</span><br><span class="line">        this.name = name;</span><br><span class="line">        this.age = age;</span><br><span class="line">    &#125;</span><br><span class="line">    public String getName() &#123;</span><br><span class="line">        return name;</span><br><span class="line">    &#125;</span><br><span class="line">    public void setName(String name) &#123;</span><br><span class="line">        this.name = name;</span><br><span class="line">    &#125;</span><br><span class="line">    public int getAge() &#123;</span><br><span class="line">        return age;</span><br><span class="line">    &#125;</span><br><span class="line">    public void setAge(int age) &#123;</span><br><span class="line">        this.age = age;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="Ⅱ、利用Serializable保存对象到本地"><a href="#Ⅱ、利用Serializable保存对象到本地" class="headerlink" title="Ⅱ、利用Serializable保存对象到本地"></a>Ⅱ、利用Serializable保存对象到本地</h3><figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">package org.raphets.democollection;</span><br><span class="line"></span><br><span class="line">import android.os.Environment;</span><br><span class="line">import android.support.v7.app.AppCompatActivity;</span><br><span class="line">import android.os.Bundle;</span><br><span class="line">import android.util.Log;</span><br><span class="line">import java.io.File;</span><br><span class="line">import java.io.FileInputStream;</span><br><span class="line">import java.io.FileNotFoundException;</span><br><span class="line">import java.io.FileOutputStream;</span><br><span class="line">import java.io.IOException;</span><br><span class="line">import java.io.ObjectInputStream;</span><br><span class="line">import java.io.ObjectOutputStream;</span><br><span class="line">import java.util.ArrayList;</span><br><span class="line">import java.util.Collections;</span><br><span class="line">import java.util.LinkedList;</span><br><span class="line">import java.util.List;</span><br><span class="line"></span><br><span class="line">public class MainActivity extends AppCompatActivity &#123;</span><br><span class="line">    @Override</span><br><span class="line">    protected void onCreate(Bundle savedInstanceState) &#123;</span><br><span class="line">        super.onCreate(savedInstanceState);</span><br><span class="line">        setContentView(R.layout.activity_main);</span><br><span class="line">        storageSerializableData();</span><br><span class="line">        getSerializableData();</span><br><span class="line">    &#125;</span><br><span class="line">    /**</span><br><span class="line">     * 存储Serializable数据到本地</span><br><span class="line">     */</span><br><span class="line">    private void storageSerializableData() &#123;</span><br><span class="line">        List&lt;Dog&gt; mDogs = new ArrayList&lt;&gt;();</span><br><span class="line">        Dog dog1 = new Dog(&quot;a&quot;, 3);</span><br><span class="line">        Dog dog2 = new Dog(&quot;b&quot;, 4);</span><br><span class="line">        Dog dog3 = new Dog(&quot;c&quot;, 2);</span><br><span class="line">        mDogs.add(dog1);</span><br><span class="line">        mDogs.add(dog2);</span><br><span class="line">        mDogs.add(dog3);</span><br><span class="line">        FileOutputStream fos = null;</span><br><span class="line">        ObjectOutputStream oos = null;</span><br><span class="line">        try &#123;</span><br><span class="line">            File file = new File(Environment.getExternalStorageDirectory().toString()</span><br><span class="line">                    + &quot;/&quot; + &quot;dogs.dat&quot;);</span><br><span class="line">            if (!file.exists()) &#123;</span><br><span class="line">                file.createNewFile();</span><br><span class="line">            &#125;</span><br><span class="line">            fos = new FileOutputStream(file.toString());</span><br><span class="line">            oos = new ObjectOutputStream(fos);</span><br><span class="line">            oos.writeObject(mDogs);</span><br><span class="line">        &#125; catch (Exception e) &#123;</span><br><span class="line">            Log.i(&quot;TAG&quot;,e.toString());</span><br><span class="line">        &#125; finally &#123;</span><br><span class="line">            try &#123;</span><br><span class="line">                if (oos != null)</span><br><span class="line">                    oos.close();</span><br><span class="line">                if (fos != null)</span><br><span class="line">                    fos.close();</span><br><span class="line">            &#125; catch (IOException e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">    /**</span><br><span class="line">     * 读取本地的Seriablizable数据</span><br><span class="line">     */</span><br><span class="line">    private void getSerializableData() &#123;</span><br><span class="line">        FileInputStream fis=null;</span><br><span class="line">        ObjectInputStream ois=null;</span><br><span class="line">        File file = new File(Environment.getExternalStorageDirectory().toString()</span><br><span class="line">                + &quot;/&quot; + &quot;dogs.dat&quot;);</span><br><span class="line">        if (file.exists())&#123;</span><br><span class="line">            try &#123;</span><br><span class="line">                fis=new FileInputStream(file.toString());</span><br><span class="line">                ois=new ObjectInputStream(fis);</span><br><span class="line">               List&lt;Dog&gt; mDogs= (List&lt;Dog&gt;) ois.readObject();</span><br><span class="line">                for (Dog dog:mDogs)&#123;</span><br><span class="line">                    Log.i(&quot;Dog&quot;,dog.getName());</span><br><span class="line">                &#125;</span><br><span class="line">            &#125; catch (Exception e) &#123;</span><br><span class="line">                e.printStackTrace();</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h1 id="四、Parcelable接口实现序列化"><a href="#四、Parcelable接口实现序列化" class="headerlink" title="四、Parcelable接口实现序列化"></a>四、Parcelable接口实现序列化</h1><p>Android的Parcelable的设计初衷是因为Serializable效率过慢，为了在程序内不同组件间以及不同Android程序间(AIDL)高效的传输数据而设计，这些数据仅在内存中存在，Parcelable是通过IBinder通信的消息的载体。</p>
<p>实现Parcelable接口主要可以分为一下几步： </p>
<p>1）implements Parcelable。 </p>
<p>2）重写writeToParcel方法，将你的对象序列化为一个Parcel对象，即：将类的数据写入外部提供的Parcel中，打包需要传递的数据到Parcel容器保存，以便从Parcel容器获取数据。 </p>
<p>3）重写describeContents方法，内容接口描述，默认返回0即可。 </p>
<p>4）实例化静态内部对象CREATOR实现接口Parcelable.Creator 。<br>注意:若将Parcel看成是一个流，则先通过writeToParcel把对象写到流里面，再通过createFromParcel从流里读取对象，因此类实现的写入顺序和读出顺序必须一致。 </p>
<figure class="highlight plaintext"><table><tr><td class="code"><pre><span class="line">package org.raphets.democollection;</span><br><span class="line">import android.os.Parcel;</span><br><span class="line">import android.os.Parcelable;</span><br><span class="line"></span><br><span class="line">public class Dog implements Parcelable&#123;</span><br><span class="line">    private String name;</span><br><span class="line">    private int age;</span><br><span class="line"></span><br><span class="line">    protected Dog(Parcel in) &#123;</span><br><span class="line">        name = in.readString();</span><br><span class="line">        age = in.readInt();</span><br><span class="line">    &#125;</span><br><span class="line">    public Dog(String name, int age) &#123;</span><br><span class="line">        this.name = name;</span><br><span class="line">        this.age = age;</span><br><span class="line">    &#125;</span><br><span class="line">    public String getName() &#123;</span><br><span class="line">        return name;</span><br><span class="line">    &#125;</span><br><span class="line">    public void setName(String name) &#123;</span><br><span class="line">        this.name = name;</span><br><span class="line">    &#125;</span><br><span class="line">    public int getAge() &#123;</span><br><span class="line">        return age;</span><br><span class="line">    &#125;</span><br><span class="line">    public void setAge(int age) &#123;</span><br><span class="line">        this.age = age;</span><br><span class="line">    &#125;</span><br><span class="line">    public static final Creator&lt;Dog&gt; CREATOR = new Creator&lt;Dog&gt;() &#123;</span><br><span class="line">        @Override</span><br><span class="line">        public Dog createFromParcel(Parcel in) &#123;</span><br><span class="line">            return new Dog(in);</span><br><span class="line">        &#125;</span><br><span class="line">        @Override</span><br><span class="line">        public Dog[] newArray(int size) &#123;</span><br><span class="line">            return new Dog[size];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;;</span><br><span class="line">    @Override</span><br><span class="line">    public int describeContents() &#123;</span><br><span class="line">        return 0;</span><br><span class="line">    &#125;</span><br><span class="line">    @Override</span><br><span class="line">    public void writeToParcel(Parcel parcel, int i) &#123;</span><br><span class="line">        parcel.writeString(name);</span><br><span class="line">        parcel.writeInt(age);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>


<h1 id="五、Parcelable和Serializable的区别："><a href="#五、Parcelable和Serializable的区别：" class="headerlink" title="五、Parcelable和Serializable的区别："></a>五、Parcelable和Serializable的区别：</h1><p>1、在使用内存的时候Parcelable比Serializable的性能高。</p>
<p>2、Serializable在序列化的时候会产生大量的临时变量，从而引起频繁的GC（内存回收）。</p>
<p>3、Parcelable不能使用在将对象存储在磁盘上这种情况，因为在外界的变化下Parcelable不能很好的保证数据的持续性。</p>
<p>4、在读写数据的时候,Parcelable是在内存中直接进行读写,而Serializable是通过使用IO流的形式将数据读写入在硬盘上</p>
<p>5、Parcelable是以Ibinder作为信息载体的.在内存上的开销比较小,因此在内存之间进行数据传递的时候,Android推荐使用Parcelable</p>
<h1 id="六、如何选择"><a href="#六、如何选择" class="headerlink" title="六、如何选择"></a>六、如何选择</h1><p>Parcelable的性能比Serializable好，在内存开销方面较小，所以在内存间数据传输时推荐使用Parcelable，如activity间传输数据。</p>
<p>而Serializable可将数据持久化方便保存，所以在需要保存或网络传输数据时选择Serializable。</p>
<p>Android不同版本Parcelable可能不同，所以在序列化到存储设备或者网络传输方面还是尽量选择Serializable接口。</p>

    </div>

    
    
    

      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/archives/49500.html" rel="prev" title="Python 操作 Mongodb 详解">
      <i class="fa fa-chevron-left"></i> Python 操作 Mongodb 详解
    </a></div>
      <div class="post-nav-item">
    <a href="/archives/9e761e8b.html" rel="next" title="SwipeRefreshLayout 首次进入界面自动刷新">
      SwipeRefreshLayout 首次进入界面自动刷新 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%A6%82%E5%BF%B5"><span class="nav-number">1.</span> <span class="nav-text">一、概念</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E7%94%A8%E9%80%94"><span class="nav-number">2.</span> <span class="nav-text">二、用途</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81Serializable%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0%E5%BA%8F%E5%88%97%E5%8C%96"><span class="nav-number">3.</span> <span class="nav-text">三、Serializable接口实现序列化</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E2%85%A0%E3%80%81Android-Studio%E8%87%AA%E5%8A%A8%E7%94%9F%E6%88%90SerizlVersionUID"><span class="nav-number">3.0.0.1.</span> <span class="nav-text">Ⅰ、Android Studio自动生成SerizlVersionUID:</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E2%85%A1%E3%80%81%E5%88%A9%E7%94%A8Serializable%E4%BF%9D%E5%AD%98%E5%AF%B9%E8%B1%A1%E5%88%B0%E6%9C%AC%E5%9C%B0"><span class="nav-number">3.0.1.</span> <span class="nav-text">Ⅱ、利用Serializable保存对象到本地</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%9B%9B%E3%80%81Parcelable%E6%8E%A5%E5%8F%A3%E5%AE%9E%E7%8E%B0%E5%BA%8F%E5%88%97%E5%8C%96"><span class="nav-number">4.</span> <span class="nav-text">四、Parcelable接口实现序列化</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%94%E3%80%81Parcelable%E5%92%8CSerializable%E7%9A%84%E5%8C%BA%E5%88%AB%EF%BC%9A"><span class="nav-number">5.</span> <span class="nav-text">五、Parcelable和Serializable的区别：</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%85%AD%E3%80%81%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9"><span class="nav-number">6.</span> <span class="nav-text">六、如何选择</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="John Doe"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">John Doe</p>
  <div class="site-description" itemprop="description">不积跬步，无以至千里；不积小流，无以成江海。</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">47</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">8</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">32</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">John Doe</span>
</div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
